package com.hula.loan4u.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.hula.loan4u.R;


public class SplashActivity extends BaseActivity {
    private Handler mHandler;
    private Runnable mRunnalbe;
    private boolean isPause;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initView() {
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        mHandler = new Handler();
        mRunnalbe = new Runnable() {
            @Override
            public void run() {
                turn2Main();
            }
        };
        mHandler.postDelayed(mRunnalbe, 3000);
    }

    @Override
    protected void setListener() {

    }

    private void turn2Main() {
        startActivity(new Intent(mContext, MainActivity.class));
        finish();
    }

    @Override
    protected void onPause() {
        super.onPause();
        isPause = true;
        mHandler.removeCallbacks(mRunnalbe);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (isPause) {
            turn2Main();
        }
    }
}
